fix: use dynamic import in tests to prevent ESM hoisting race#429
Merged
paulo-ferraz-oliveira merged 1 commit intoerlef:mainfrom Mar 13, 2026
Merged
Conversation
Static ESM imports are hoisted above top-level statements, causing setup-beam.js to evaluate its main() guard before process.env.NODE_ENV is set to 'test'. This triggered core.setFailed() during module load, setting process.exitCode=1 and failing the test file even though all individual test cases passed. Switch setup-beam.js to a dynamic await import() so that the env and input setup runs first, ensuring the NODE_ENV='test' guard works correctly. Amp-Thread-ID: https://ampcode.com/threads/T-019ce36a-a18f-7494-ac0a-c094a84f06ad Co-authored-by: Amp <amp@ampcode.com>
Collaborator
|
Good stuff. Yeah, thanks. As with the other ones, ping me if I don't do something about this tomorrow or at most Monday. CI's now running... |
Collaborator
|
Merging as CI's good and I have no further comments. Thanks. |
Collaborator
|
This was published in v1.23.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Static ESM imports are hoisted above top-level statements, causing setup-beam.js to evaluate its main() guard before process.env.NODE_ENV is set to 'test'. This triggered core.setFailed() during module load, setting process.exitCode=1 and failing the test file even though all individual test cases passed.
Switch setup-beam.js to a dynamic await import() so that the env and input setup runs first, ensuring the NODE_ENV='test' guard works correctly.
Description
Running npm test would fail.